package org.example.Controller;

import org.example.Service.BookService;
import org.example.domain.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.print.DocFlavor;

@RestController
@RequestMapping("/book")
public class BookController {

    @Autowired
    private BookService bookService;

    @PostMapping
    public String save(@RequestBody  Book book){
        System.out.println("save");
        return bookService.save(book);
    }

   @DeleteMapping("{id}")

    public String delete( @PathVariable Integer id){
        System.out.println("delete");
       return bookService.delete(id);
    }
    @PutMapping
    public String update(@RequestBody Book book){
        System.out.println("update");
        return bookService.update(book);
    }
    @GetMapping("{id}")
    public String getById(@PathVariable Integer id){
        System.out.println("getById");
        return bookService.getById(id);
    }
    @GetMapping
    public String getAll(){
        System.out.println("getAll");
        return bookService.getAll();
    }

}
